//
//  TryAgainView.m
//  HousingPoliceAssistant
//
//  Created by 云警01 on 2019/6/6.
//  Copyright © 2019 盛洋. All rights reserved.
//

#import "TryAgainView.h"

@implementation TryAgainView


- (IBAction)scrBtnClicked:(id)sender {
    [self loadingStart];
    if(_delegate && [_delegate respondsToSelector:@selector(ScreenBtnClicked)]){
        [_delegate ScreenBtnClicked];
    }
}


-(void)loadingStart{
    [self setHidden:NO];
    [_loading setHidden:NO];
    [_infoTxt setText:@"正在加载…"];
    [_scrBtn setHidden:YES];
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
    rotationAnimation.duration = 1.5;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 9999;
    [_loading.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

}

-(void)loadingError{
    [self setHidden:NO];
    [_loading setHidden:YES];
    
    [_infoTxt setText:@"加载失败，点击重新加载"];
    [_scrBtn setHidden:NO];
    
    [_loading.layer removeAllAnimations];
    
}

-(void)loadingFinished{
    [self setHidden:YES];
    [_loading.layer removeAllAnimations];
}

@end
